package com.demo.api.conf;

import com.demo.api.repository.RedisCacheRepository;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: cja
 * @date: 2019/11/14 15:23
 */
public class GlobalInterceptor extends HandlerInterceptorAdapter {
    @Autowired
    private RedisCacheRepository cacheRepository;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        /*String tokenKey = request.getHeader("sys-token");
        if (StringUtils.isEmpty(tokenKey) || StringUtils.isEmpty(cacheRepository.get(tokenKey))) {
            throw new BussException(ResultT.CLIENT_ERROR_CODE, "权限验证错误");
        }
        String tokenValue = cacheRepository.get(tokenKey);
        cacheRepository.set(tokenKey, tokenValue, 10 * 60 * 60);*/
        return true;
    }
}
